package com.pengcheng.taskapplication.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.pengcheng.taskapplication.R;
import com.pengcheng.taskapplication.model.SortModel;
import com.pengcheng.taskapplication.model.WalletModel;
import com.pengcheng.taskapplication.mvp.view.widget.CircleImageView;

import java.util.List;

public class PayTypeAdapter extends BaseAdapter {

	Context context;
	LayoutInflater inflater;
	List<SortModel> sortModels;
	int last_item;
	private int selectedPosition = -1;
	public PayTypeAdapter(Context context, List<SortModel> sortModels){
		this.context = context;
		this.sortModels = sortModels;
		inflater= LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return sortModels.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return sortModels.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder  holder = null;
		if(convertView==null){
			convertView = inflater.inflate(R.layout.paytype_listview_item, null);
			holder = new ViewHolder();
			holder.tv_name=(TextView) convertView.findViewById(R.id.tv_name);
			convertView.setTag(holder);
		}
		else{
			holder=(ViewHolder)convertView.getTag();
		}

		SortModel model= sortModels.get(position);
		holder.tv_name.setText(model.getName());
		return convertView;
	}

	public static class ViewHolder{
		public TextView tv_name;

	}

	public void setSelectedPosition(int position) {
		selectedPosition = position;
	}

}
